<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>sessionStorage</title>
</head>
<body>
<h1>sessionStorage</h1>
<button onclick="saveData()">点我保存一个数据</button>
<button onclick="readData()">点我读取一个数据</button>
<button onclick="deleteData()">删除一个数据</button>
<button onclick="clearData()">清空所有数据</button>
<script>
    function saveData(){
        sessionStorage.setItem('message','今天天气真不错')
        sessionStorage.setItem('msg',123456887)
        const person={name:'李四',sex:'男'}
        sessionStorage.setItem('person',JSON.stringify(person))
    }
    function readData(){
        console.log(sessionStorage.getItem('message'));
        console.log(sessionStorage.getItem('msg'));
        const p=sessionStorage.getItem('person')
        console.log(JSON.parse(p));
        console.log("-----------------------------------------")
    }
    function deleteData(){
        sessionStorage.removeItem('msg')
    }
    function clearData(){
        sessionStorage.clear()
    }
</script>
</body>
</html>
